Skip to content

fix(table): Use ansi.Truncate instead of runewidth.Truncate#883

Closed
jedevc wants to merge 1 commit intocharmbracelet:masterfrom
jedevc:fix-table-truncate
Closed

fix(table): Use ansi.Truncate instead of runewidth.Truncate#883
jedevc wants to merge 1 commit intocharmbracelet:masterfrom
jedevc:fix-table-truncate

Conversation

@jedevc
Copy link

@jedevc jedevc commented Feb 12, 2026

runewidth.Truncate does not consider terminal escape characters - this means that if a table cell contains funky characters, then it will be incorrectly truncated.

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

Minimal reproducer:

package main

import (
	"fmt"

	"github.com/charmbracelet/bubbles/table"
	"github.com/charmbracelet/lipgloss"
)

func main() {
	cols := []table.Column{{Title: "Name", Width: 7}}
	value := lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Render("ABCDEFGH")
	rows := []table.Row{{value}}

	t := table.New(
		table.WithColumns(cols),
		table.WithRows(rows),
	)

	fmt.Println(t.View())
}

Before:

image

After:

image

runewidth.Truncate does not consider terminal escape characters - this
means that if a table cell contains funky characters, then it will be
incorrectly truncated.

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc jedevc requested a review from aymanbagabas as a code owner February 12, 2026 15:04
@andreynering
Copy link
Member

Hi @jedevc, and thanks for contributing!

We're avoiding making changes on the master branch because we have ongoing development on v2 on the v2-exp branch.

I suggest you to try the release candidate to see if the issue persists there, and if so you're free to open another PR targeting that branch.

@jedevc
Copy link
Author

jedevc commented Feb 12, 2026

I can check and reopen for sure 🎉 sorry, hadn't noticed you were doing prep for v2!

I did see this comment charmbracelet/bubbletea#1374 (reply in thread) in the main bubbletea repo that mentioned how fixes could be applied across main and v2 branches?

Not sure if that's the same scheme as here (or if that's changed), or when v2 is targeted for, but I'm using bubbletea quite extensively, and can't easily update to the rc fully, at least until it's all fully stable.

@andreynering
Copy link
Member

@jedevc At this point, we don't expect any more breaking changes before launch. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants